// @ts-nocheck
import { NetPacket } from "@/netBase/NetPacket";
import PKwebsocket from "@/lolo/Ws.ts"
import { Local } from "./storage";
// 添加取消收藏
export const reqCollect = async (game: any, allCollected: any) => {
    const query = NetPacket.req_modify_collect()
    query.agentId = game.agentId || game.id  //id 为厂商游戏  例如 体育 真人之类
    query.id = game.id
    query.type = allCollected.includes(query.id) ? 1 : 0
    Local.set('gameId', query.id)
    PKwebsocket.instance.send(query, true)
}
// 请求第三方游戏url
export const getGameUrl = async (item: any, lang: string, Page: any) => {
    Page.setGameIsLoading(true)
    Local.set('direction', item.direction || 0)
    let tb = NetPacket.req_3rd_game_login();
    tb.agentId = item.agentId || item.id //platform.three_game_kind_id;
    tb.gameId = item.gameId //platform.three_platform_id;
    tb.kindId = item.kindId //|| item.venue_id //platform.venue_id;
    tb.lang = Number(lang);
    tb.device_type = 2  //2 为手机浏览器打开  后期使用此方法 getBlientType
    console.log('%c@@@@tb req_3rd_game_login', 'background: gray; color: white; font-size: 16px;', tb);
    PKwebsocket.instance.send(tb, true, {
        callbackName: 'msg_notify_3rd_game_login_result',
        callback: (res: any) => {
            console.log('%c@@@@res msg_notify_3rd_game_login_result', 'background: gray; color: white; font-size: 16px;', res);
        }
    })
}
// 请求自研三方游戏Url
export const getSelfGameUrl = async (item: any, lang: string, Page: any) => {
    Page.setGameIsLoading(true)
    Local.set('direction', item.direction || 0)
    let tb = NetPacket.req_3rd_game_login();
    tb.agentId = 88888888
    tb.gameId = item.room_id
    tb.lang = Number(lang);
    tb.device_type = 2  //2 为手机浏览器打开  后期使用此方法 getBlientType
    PKwebsocket.instance.send(tb, true)
}

// 发送请求并处理游戏 收藏和最近的数据
export const repMyGamesData = (onHandleGames: (res: any) => void) => {
    // 创建请求包
    const req = NetPacket.req_my_games();
    // 发送请求
    PKwebsocket.instance.send(req, true, {
        callbackName: 'msg_notify_req_my_games',
        callback: (res: any) => onHandleGames(res),
    });
};
